#ifndef AURASIM_H
#define AURASIM_H

#include <QObject>
#include "ecs/systemmanager.h"
#include "ecs/entitymanager.h"
#include "ecs/entity.h"
#include "utils/entityfactory.h"
#include <QSharedPointer>
#include <QGraphicsItem>
#include <QTime>

namespace Aurasim {

enum SimState{
    Stop,
    Start
};

class AurasimApp : public QObject
{
    Q_OBJECT

public:
    explicit AurasimApp(QObject *parent = nullptr);
    static AurasimApp* instance();

    QSharedPointer<SystemManager> systemManager;
    QSharedPointer<EntityManager> entityManger;
    EntityList selectedEntities;
    bool mouseDraggingState;
    SimState simState;
    QSharedPointer<Entity> board;

signals:
    void simStateChanged(const SimState& state);

public slots:
    void updateSelectedEntity(QList<QGraphicsItem*> items);

protected:
    void timerEvent(QTimerEvent* e);

private:
    QTime mTimerCounter;
};


// app global fuctions
void init();
AurasimApp* app();
const QSharedPointer<SystemManager>& systemManager();
const QSharedPointer<EntityManager>& entityManager();
const EntityList& selectedEntities();
void setMouseDraggingState(const bool& state);
bool mouseDraggingState();
void startSim();
void stopSim();
}

#endif // AURASIM_H
